/**
 * 系统状态常量定义
 * 统一管理各种状态的文本值
 */

// 单据状态
export const BILL_STATUS = {
  DRAFT: "草稿",
  FORMAL: "正文",
} as const;

// 工作流状态
export const WORKFLOW_STATUS = {
  PENDING: "待提交",
  SUBMITTING: "提交中",
  REVIEWING: "审核中",
  COMPLETED: "已完成",
  CANCELLED: "已取消",
} as const;

// 辞退类型
export const RESIGN_TYPE = {
  PROBATION_UNQUALIFIED: "试用期不合格",
  SERIOUS_VIOLATION: "严重违纪",
  SERIOUS_DERELICTION: "严重失职或舞弊",
  CONCURRENT_POSITION_REFUSAL: "兼岗影响履职且拒不改正",
  FRAUDULENT_ENTRY: "欺诈入职或合同无效",
  CRIMINAL_RESPONSIBILITY: "刑事责任",
  CONFIDENTIALITY_VIOLATION: "违反保密或竞业",
  OTHER: "其他",
} as const;

// 待办中心状态
export const TODO_STATUS = {
  PENDING: "待办",
  COMPLETED: "已办",
  COLLABORATED: "已协同",
  MY_SUBMISSION: "我的提交",
} as const;

// 状态颜色映射（用于徽章显示）
export const STATUS_COLOR_MAP: Record<string, string> = {
  // 工作流状态颜色
  "待提交": "gray",
  "提交中": "blue",
  "审核中": "orange",
  "已完成": "green",
  "已取消": "red",

  // 待办状态颜色
  "待办": "orange",
  "已办": "green",
  "已协同": "blue",
  "我的提交": "purple",
};

// 状态样式类映射
export const STATUS_CLASS_MAP: Record<string, string> = {
  "待提交": "status-pending",
  "提交中": "status-submitting",
  "审核中": "status-reviewing",
  "已完成": "status-completed",
  "已取消": "status-cancelled",
};

/**
 * 获取状态颜色
 * @param status 状态文本
 * @returns 颜色值
 */
export function getStatusColor(status: string | undefined | null): string {
  if (!status) return "gray";
  return STATUS_COLOR_MAP[status] || "gray";
}

/**
 * 获取状态样式类
 * @param status 状态文本
 * @returns 样式类名
 */
export function getStatusClass(status: string | undefined | null): string {
  if (!status) return "status-unknown";
  return STATUS_CLASS_MAP[status] || "status-unknown";
}

// 状态选项数组（用于筛选器）
export const BILL_STATUS_OPTIONS = [BILL_STATUS.DRAFT, BILL_STATUS.FORMAL];
export const WORKFLOW_STATUS_OPTIONS = [
  WORKFLOW_STATUS.PENDING,
  WORKFLOW_STATUS.SUBMITTING,
  WORKFLOW_STATUS.REVIEWING,
  WORKFLOW_STATUS.COMPLETED,
  WORKFLOW_STATUS.CANCELLED
];
export const RESIGN_TYPE_OPTIONS = [
  RESIGN_TYPE.PROBATION_UNQUALIFIED,
  RESIGN_TYPE.SERIOUS_VIOLATION,
  RESIGN_TYPE.SERIOUS_DERELICTION,
  RESIGN_TYPE.CONCURRENT_POSITION_REFUSAL,
  RESIGN_TYPE.FRAUDULENT_ENTRY,
  RESIGN_TYPE.CRIMINAL_RESPONSIBILITY,
  RESIGN_TYPE.CONFIDENTIALITY_VIOLATION,
  RESIGN_TYPE.OTHER
];

// 类型定义
export type BillStatusType = typeof BILL_STATUS[keyof typeof BILL_STATUS];
export type WorkflowStatusType = typeof WORKFLOW_STATUS[keyof typeof WORKFLOW_STATUS];
export type ResignTypeType = typeof RESIGN_TYPE[keyof typeof RESIGN_TYPE];
export type TodoStatusType = typeof TODO_STATUS[keyof typeof TODO_STATUS];
